<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

</head>

<body>
    <script>
        let p = new Promise((resolve, reject) => {
            let isSuccess = true;
            if (isSuccess) {
                resolve("ok正确");
            } else {
                reject("error-错误");
            }
        });

        // .then(resolve, reject) 两个参数， resolve和reject都可能在 .then 中有处理函数。
        p.then(
            (res) => {
                console.log("resolve:", res);
            },
            (err) => {
                console.log("error:", err);
            },
        );

        // .then(); 只有一个参数，那么resolve()会执行.then()    regect()会执行.catch()
        p.then((res) => {
            console.log("resolve()会执行.then()", res);
        }).catch((err) => {
            console.log("regect()会执行.catch()", err);
        })
    </script>

</body>

</html>